<!-- <header class="uc_head">
	<h3>建议列表</h3>
</header> -->

{set:$querySuggestionList = Api::run('getUcenterSuggestion',$this->user['user_id'])}
{set:$querySuggestion = $querySuggestionList->find()}
{if:$querySuggestion}


{/if}
{$querySuggestionList->getPageBar()}

<header class="uc_head">
	<h3>百度地图</h3>
</header>

<section class="user_form">
	
		<dl>
			<dt>地址:</dt>
			<dd>
				<input name="title" id="address" type="text" pattern='required' alt='地址不能为空' class="input_text" />
			
			</dd>
			<dd><input class="input_submit" id="search" value="搜索" /></dd>
			<dd><input class="input_submit" id="button" value="展示地图" /></dd>

		</dl>
		<dl>
			<dt></dt>
			<dd><div id="allview" style="width: 500px;height: 300px"></div></dd>
		
			<dd><div id="map" style="width: 500px;height: 300px"></div></dd>
		</dl>
	
</section>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=rmsgVig8ytPtOhrTlt2MvNDBqxw4UWpQ"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<script type="text/javascript"> 
	$("#search").click(function(){
	    var address = $("#address").val();
		$.ajax({
			url:'{url:/shop/lngandlat}',
			data:{address:address},
			dataType:'json',
			type :'post',
			success:function(res)
			{
				var lng = res.lng;
				var lat = res.lat;	
				var panorama = new BMap.Panorama('allview');
				panorama.setPosition(new BMap.Point(lng, lat));
				panorama.addEventListener('position_changed', function(e){ //全景位置改变事件
				   panoramaCallBack(e);
				});
				panorama.addEventListener('pov_changed', function(e){ //全景视角改变事件
					panoramaCallBack(e);
				});
				function panoramaCallBack(e){ //事件回调函数
					if (e.type == 'onpov_changed') { 
						document.getElementById('svInfoText').innerHTML="全景视角为：<br/>"+"水平视角："+panorama.getPov().heading+"<br/>垂直视角："+panorama.getPov().pitch;
					}
					else if (e.type=='onposition_changed') {
						document.getElementById('svInfoText').innerHTML="全景位置点为："+panorama.getPosition().lng+","+panorama.getPosition().lat;
					}
				}
   
				
			
		    }
		})
	})
	$("#button").click(function(){
	    var address = $("#address").val();
		$.ajax({
			url:'{url:/shop/lngandlat}',
			data:{address:address},
			dataType:'json',
			type :'post',
			success:function(res)
			{
				var lng = res.lng;
				var lat = res.lat;				
				var map = new BMap.Map("map");
				var point = new BMap.Point(lng,lat);
				map.centerAndZoom(point,15);
				var geoc = new BMap.Geocoder();    

				map.addEventListener("click", function(e){        
					var pt = e.point;
					geoc.getLocation(pt, function(rs){
						var addComp = rs.addressComponents;
						alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
					});        
				});

   
				
			
		         }
		})
	})
	
</script>
